//
//  test1ViewController.m
//  CargocnRun
//
//  Created by mac on 2018/11/22.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "test1ViewController.h"
#import "test2ViewController.h"
@interface test1ViewController ()<UITableViewDelegate,UITableViewDataSource,UIScrollViewDelegate,UISearchControllerDelegate,UISearchResultsUpdating,UISearchBarDelegate>
@property (nonatomic,strong) UITableView *tableView;
@property (nonatomic,strong) NSArray *dataArray;
@property (nonatomic,assign) NSInteger num;
@end

@implementation test1ViewController
-(void)viewWillAppear:(BOOL)animated
{
//    self.navigationController.navigationBar.hidden = NO;
//    [self addNaviBarColor];
//    [self addBackNaviLeftItem];
//    [self addHomePageNaviRightItemByImg:@"tab0"];
    self.navigationItem.title = @"首页";
    self.navigationController.navigationBar.prefersLargeTitles = YES;//这句话表示是否显示大标题
    self.navigationItem.largeTitleDisplayMode =  UINavigationItemLargeTitleDisplayModeAutomatic;//这个是标题显示的方式，下面会详细的说
//    [self.navigationController.navigationBar setLargeTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName,nil,NSFontAttributeName,nil]];
    
    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(20, 50, ScreenWidth-40, 40)];
    
    
    UISearchController *search = [[UISearchController alloc] initWithSearchResultsController:nil];
//    search.searchBar.frame = CGRectMake(0, 200, 300, 40);
    search.searchBar.placeholder = @"请搜索内容";
    search.delegate = self;
    search.searchResultsUpdater = self;
    
    search.searchBar.backgroundImage = [UIImage imageNamed:@"clearImage"];
    search.searchBar.barTintColor = [UIColor whiteColor];
    search.searchBar.delegate = self;
    UITextField *searchField = [search.searchBar valueForKey:@"searchField"];
    if (searchField)
    {
        [searchField setBackgroundColor:[UIColor whiteColor]];
        searchField.layer.cornerRadius = 14.0f;
        // searchField.layer.borderColor = [UIColor colorWithRed:247/255.0 green:75/255.0 blue:31/255.0 alpha:1].CGColor;
        // searchField.layer.borderWidth = 1;
        searchField.layer.masksToBounds = YES;
        
    }

//    [view1 addSubview:search.searchBar];
    
    self.navigationItem.searchController = search;
    self.navigationItem.hidesSearchBarWhenScrolling = NO;

}

-(void)togogooo
{
    self.dataArray = @[@"1",@"22",@"333",@"444",@"555",@"666",@"666",@"777",@"888",@"999",@"000",@"999",@"999",@"000",@"999",@"999",@"000",@"999",@"999",@"000",@"999",@"999",@"000",@"999",@"999",@"000",@"999",@"999",@"000",@"999",@"999",@"000",@"999",@"999",@"000",@"999",@"999",@"000",@"999",@"999",@"000",@"999",@"999",@"000",@"999",@"999",@"000",@"999",@"999",@"000",@"999",@"999",@"000",@"999",@"999",@"000",@"999"];
    [self.tableView reloadData];
}

- (void)viewDidLoad {
    self.dataArray = @[@"11",@"212",@"3331",@"4441",@"5551",@"6661",@"6661",@"7771",@"8881",@"9991",@"0001",@"9991",@"22",@"333",@"444",@"555",@"666",@"22",@"333",@"444",@"555",@"666",@"22",@"333",@"444",@"555",@"666",@"22",@"333",@"444",@"555",@"666",@"22",@"333",@"444",@"555",@"666",@"22",@"333",@"444",@"555",@"666",@"22",@"333",@"444",@"555",@"666"];
    self.title = @"我是标题";
    [super viewDidLoad];
//    self.view.backgroundColor = [UIColor redColor];
    self.num = 30;
    ILog(@"%f---%f",40*ScaleRate*self.num,40*ScaleRate);
    
//    UISearchController *search = [[UISearchController alloc] initWithSearchResultsController:nil];
//    search.searchBar.frame = CGRectMake(0, 200, 300, 40);
//    search.searchBar.placeholder = @"请搜索内容";
//    search.delegate = self;
//    search.searchResultsUpdater = self;
//
//    search.searchBar.backgroundImage = [UIImage imageNamed:@"clearImage"];
//    search.searchBar.barTintColor = [UIColor whiteColor];
//    search.searchBar.delegate = self;
//    UITextField *searchField = [search.searchBar valueForKey:@"searchField"];
//    if (searchField)
//    {
//        [searchField setBackgroundColor:[UIColor whiteColor]];
//        searchField.layer.cornerRadius = 14.0f;
//        // searchField.layer.borderColor = [UIColor colorWithRed:247/255.0 green:75/255.0 blue:31/255.0 alpha:1].CGColor;
//        // searchField.layer.borderWidth = 1;
//        searchField.layer.masksToBounds = YES;
//
//    }
//    [self.view addSubview:search.searchBar];
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 400) style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    
    
    UIButton *BTN = [[UIButton alloc] initWithFrame:CGRectMake(0, ScreenHeight-XIndicator-40, ScreenWidth, 40)];
    [BTN setTitle:@"我是按钮" forState:UIControlStateNormal];
    [BTN setBackgroundColor:KBLUECOLOR];
//    BTN.alpha = 0.2;
    [BTN addTarget:self action:@selector(topush) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:BTN];
}
-(void)topush
{
    test2ViewController *wallet = [[test2ViewController alloc] init];
    self.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:wallet animated:YES];
    self.hidesBottomBarWhenPushed = YES;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *identifier = @"Indentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.text = [self.dataArray objectAtIndex:indexPath.row];
    return cell;
    
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataArray.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 40*ScaleRate;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self topush];
}
-(void)updateSearchResultsForSearchController:(UISearchController *)searchController
{
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
